<?php

/**
 * Articulo form base class.
 *
 * @method Articulo getObject() Returns the current form's model object
 *
 * @package    dirsac
 * @subpackage form
 * @author     Miguel Flores
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseArticuloForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'             => new sfWidgetFormInputHidden(),
      'nombre'         => new sfWidgetFormInputText(),
      'especificacion' => new sfWidgetFormTextarea(),
      'tipo_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TipoArticulo'), 'add_empty' => false)),
      'medida_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Medida'), 'add_empty' => false)),
      'largo'          => new sfWidgetFormInputText(),
      'alto'           => new sfWidgetFormInputText(),
      'ancho'          => new sfWidgetFormInputText(),
      'peso'           => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'             => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'nombre'         => new sfValidatorString(array('max_length' => 255)),
      'especificacion' => new sfValidatorString(array('max_length' => 1000, 'required' => false)),
      'tipo_id'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TipoArticulo'))),
      'medida_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Medida'))),
      'largo'          => new sfValidatorNumber(array('required' => false)),
      'alto'           => new sfValidatorNumber(array('required' => false)),
      'ancho'          => new sfValidatorNumber(array('required' => false)),
      'peso'           => new sfValidatorNumber(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('articulo[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Articulo';
  }

}
